
#include "MikrotikAPI.h"
#include "FirewallSetting.h"
#include <string>
#include<iostream>
using namespace std;

void usage(void);

int main(int argc, char* argv[])
{
	string ip = "192.168.1.24";
	string username = "admin";
	string password = "admin";


	int result =RosAPI->Login(ip, username, password, 8728);
	if(result<0)
	{
		return 0;
	}

	usage();

	while(true)
	{
		int cmd=0;
		std::string ip;
		bool print_all =false;
		std::cin >>cmd >>ip;
		if(cmd==1)
		{
			FirewallSetting::remove_address_list(ip);
		}
		else if(cmd==2)
		{
			std::string limit_ip;
			std::cout<<"限制ip："<<std::endl;
			std::cin>>limit_ip;
			FirewallSetting::add_address_list(ip,limit_ip);
		}
		else if(cmd==3)
		{
			std::string address_list;
			std::cout<<"限制列表："<<std::endl;
			std::cin>>address_list;
			FirewallSetting::add_filter("input",ip,address_list);
		}
		else if(cmd==4)
		{
			FirewallSetting::remove_filter(ip);
		}
		else if(cmd==5)
		{
			cin >>print_all;
			FirewallSetting::print_addrees_list(ip,print_all);
		}
		else if(cmd==6)
		{
			StrVector vec;
			FirewallSetting::find_addrees_list(ip,vec);
		}
		else if(cmd==7)
		{
			StrVector vec;
			FirewallSetting::find_filter(ip,vec);
		}
	}
	return 0;
}

void usage(void)
{
	std::cout<<"1----------->remove address list"<<std::endl;
	std::cout<<"2----------->add_address_list"<<std::endl;
	std::cout<<"3----------->add_filter"<<std::endl;
	std::cout<<"4----------->remove_filter"<<std::endl;
	std::cout<<"5----------->print_addrees_list"<<std::endl;
	std::cout<<"6----------->find_addrees_list"<<std::endl;
	std::cout<<"7----------->find_filter"<<std::endl;
}
